package manager;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LogManager {
    private static final String LOG_FILE = "system_log.txt";

    // 记录操作日志
    public static void log(String operation, String operator) {
        SimpleDateFormat sdf = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]");
        String log = sdf.format(new Date()) + " 操作类型：" + operation + " | 操作人：" + operator + "\n";

        try (PrintWriter out = new PrintWriter(new FileWriter(LOG_FILE, true))) {
            out.write(log);
        } catch (IOException e) {
            System.out.println("日志记录失败：" + e.getMessage());
        }
    }
}